<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
	<th:block th:include="include :: header('表格数据汇总')" />
</head>
<body class="gray-bg">
     <div class="container-div">
		<div class="row">
			<div class="col-sm-12 search-collapse">
				<form id="formId">
					<div class="select-list">
						<ul>
							<li>
								员工编号：<input type="text" name="employeeCode"/>
							</li>

							<li>
								员工姓名：<input type="text" name="employeeName"/>
							</li>

							<li>
								员工手机：<input type="text" name="employeePhone"/>
							</li>

							<li>
								员工邮箱：<input type="text" name="employeeEmail"/>
							</li>

							<li>
								员工状态：<select name="status" th:with="type=${@dict.getType('sys_normal_disable')}">
									<option value="">所有</option>
									<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
								</select>
							</li>

							<li>
								<a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
								<a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
							</li>
						</ul>
					</div>
				</form>
			</div>
			
	        <div class="btn-group-sm" id="toolbar" role="group">
				<a class="btn btn-success" onclick="$.operate.add()">
					<i class="fa fa-plus"></i> 添加
				</a>
				<a class="btn btn-primary btn-edit disabled" onclick="$.operate.edit()">
					<i class="fa fa-edit"></i> 修改
				</a>
				<a class="btn btn-danger btn-del btn-del disabled" onclick="$.operate.removeAll()">
					<i class="fa fa-remove"></i> 删除
				</a>
				<a class="btn btn-warning" onclick="$.table.exportExcel()">
						<i class="fa fa-download"></i> 导出
				 </a>
			</div>
			<div class="col-sm-12 select-table table-striped">
				<table id="bootstrap-table" data-mobile-responsive="true"></table>
			</div>
		</div>
	</div>
    <div th:include="include :: footer"></div>
    <script th:inline="javascript">
        var prefix = ctx + "tool/employee";
        var sexDatas = [[${@dict.getType('sys_user_sex')}]];
        var statusDatas = [[${@dict.getType('sys_normal_disable')}]];

        $(function() {
            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
				exportUrl: prefix + "/export",
                modalName: "员工",
		        showExport: true,
		        showFooter: true,
                columns: [{
		            checkbox: true
		        },
				{
					field : 'employeeId', 
					title : '员工ID',
					visible: false
				},
				{
					field : 'employeeCode', 
					title : '员工编号',
					sortable: true
				},
				{
					field : 'employeeName', 
					title : '员工姓名',
					sortable: true
				},
				{
                    field: 'employeeSex',
                    title: '员工性别',
                    align: 'center',
                    formatter: function(value, row, index) {
                    	return $.table.selectDictLabel(sexDatas, value);
                    }
                },
				{
					field : 'employeePhone', 
					title : '员工手机',
					sortable: true
				},
				{
					field : 'employeeEmail', 
					title : '员工邮箱',
					sortable: true
				},
				{
				    field : 'employeeBalance',
				    title : '员工余额',
				    sortable: true,
				    footerFormatter:function (value) {
				    	var sumBalance = 0;
				        for (var i in value) {
				        	sumBalance += parseFloat(value[i].employeeBalance);
				        }
				        return "总金额：" + sumBalance;
				    }
				},
				{
                    field: 'status',
                    title: '员工状态',
                    align: 'center',
                    formatter: function(value, row, index) {
                    	return $.table.selectDictLabel(statusDatas, value);
                    }
                },
		        {
		            title: '操作',
		            align: 'center',
		            formatter: function(value, row, index) {
		            	var actions = [];
		            	actions.push('<a class="btn btn-success btn-xs" href="#" onclick="$.operate.edit(\'' + row.employeeId + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                        actions.push('<a class="btn btn-danger btn-xs" href="#" onclick="$.operate.remove(\'' + row.employeeId + '\')"><i class="fa fa-remove"></i>删除</a>');
						return actions.join('');
		            }
		        }]
            };
            $.table.init(options);
        });
    </script>
</body>
</html>